package com.atguigu.map;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * @program: IDEAcode
 * @description:应付面试，实际开发不适用
 * @author: Mr.zjx
 * create: 2021-08-03-16-48
 **/
public class entrySetMap {
    public static void main(String[] args) {
        //创建Map集合，键是字符串，值是整数
        Map<String,Integer> map = new HashMap<String,Integer>();
        map.put("c++",15000);
        map.put("java",14000);
        map.put("UI",12000);
        map.put("php",13000);
        //entrySet获取集合键和值
        Set<Map.Entry<String,Integer>> set = map.entrySet();
        /*Iterator<Map.Entry<String, Integer>> it = set.iterator();
        while (it.hasNext()){
            Map.Entry<String, Integer> entry = it.next();
            String key = entry.getKey();
            Integer value = entry.getValue();
            System.out.println(key + " = " + value);
        }*/
        for (Map.Entry<String,Integer> entry : set){
            System.out.println(entry.getKey()+"="+entry.getValue());
        }
    }
}
